	package com.junittest.code;
	import java.lang.*;

	public class Vector {
		
		private float x,y,z;

		public Vector()
		{
			this.x = 0.0f;
			this.y = 0.0f;
			this.z = 0.0f;
		}

		public Vector(float x, float y, float z) 
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
		public static float dotProduct(Vector v1, Vector v2)
		{
			return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z);
		}
		
		public static Vector crossProduct(Vector v1, Vector v2)
		{
			Vector v = new Vector();
			v.x = v1.y*v2.z - v1.z*v2.y; //aybz - azby
			v.y = v1.z*v2.x - v1.x*v2.z; //azbx - axbz
			v.z = v1.x*v2.y - v1.y*v2.x; //axby - aybx
			return v;
		}

		public static Vector normalize(Vector v1)
		{
			Vector v = clone(v1);
			float l = length(v);
			v.x = v.x / l;
			v.y = v.y / l;
			v.z = v.z / l;
			return v;
		}

		public static float length(Vector v1)
		{
			return (float) Math.sqrt(Math.pow(v1.x,2)+Math.pow(v1.y,2)+Math.pow(v1.z,2));
		}

		public static Vector clone(Vector v1)
		{
			Vector clone = new Vector(v1.x, v1.y, v1.z);
			return clone;
		}

		public static double dotTwoDigits(float i)
		{
			return Math.round( i * 100.0 ) / 100.0;
		}

		public static String getPositionStr(Vector v1)
		{
			return "x: " + v1.x + ", y: " + v1.y + ", z: " + v1.z;
		}

		public static boolean isPerpendicular(Vector v1, Vector v2)
		{
			if (dotProduct(v1,v2) == 0.0f)
				return true;
			return false;
		}
	}
